const insertSort = (arr = []) => {
    let newArr = [arr[0]];
    for (let i = 1; i < arr.length; i++) {
        if (arr[i] < newArr[0]) {
            newArr.unshift(arr[i])
            continue
        }
        for (let j = newArr.length - 1; j >= 0; j--) {
            if (arr[i] > newArr[j]) {
                newArr.splice(j+1, 1, arr[i])
                break
            }
        }
    }
    return newArr
}
const arr = [1, 2, 3, 0, -1, 9, 1]
const newArr = insertSort(arr)
console.log(newArr);
